#include <stdio.h>
#include <time.h>
#include <float.h>
#include <math.h>

#include <vector> //Ne pas oublier !

#include <fstream>
#include <iostream>
#include <complex>
#include <vector>
#include <iomanip> // for cout << setprecision(n)
#include <ctime>

#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>

#include <omp.h>
#include <cmath>

using namespace std ;




  double test_function(const double a, const double b)
  {
  
  double c = 0. ; 
  c = a*b/5  ; 
  
  return c ; 
  
  }





  int main()
  {

	 double wtime;
	 clock_t t;
	
	 t = clock();
	 wtime = omp_get_wtime();
	
   double test = 0 ; 
   
   int N_z = 120 ; 
   
   
	// --------------



    omp_set_num_threads(4);

 

    vector<double> result_B(N_z,1.0) ; 
    vector<double> result_A(N_z,1.0) ;


    vector<double> Ni_up(N_z,1.0) ;
    vector<double> Ni_down(N_z,1.0) ;

		double ky = 0. ; 

    vector<double> kvector(N_z,1.0) ;

		for(int n=0; n<N_z; n++)
			{       
				kvector[n] = 3.11154548775454*n/N_z ; 

			}


      for(int l=0; l<10; l++)
      {    
      
        test = 0 ; 
      
         for(int m=0; m<1; m++)
         {
      
                #pragma omp parallel
                {
                    
                    #pragma omp for
                    for(int n=0; n<N_z; n++)
                       {       
                          result_A[n] = test_function(kvector[n] , result_B[n] ) ; 
                          result_B[n] = pow(result_A[n]*result_A[n],0.4) ; 
                    
                       }
                    
                }
              
          
                  for(int n=0; n<N_z; n++)
                   {       
                      test +=  result_B[n]  ;
                    // cout <<  result_B[n] << endl ;
                   }
          
        }
      
      
      }





	// -----------
	
	t = clock() - t;
	wtime = omp_get_wtime ( ) - wtime;
	
	cout << "\n" << setw(14) << wtime << "\n";
	printf ("It took me %d clicks (%f seconds).\n",t,((float)t)/CLOCKS_PER_SEC);



  }
